<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>源生滚球盘数据</title>
    
	<style type="text/css">
	#mytable {
	    width: 100%;
	    padding: 0;
	    margin: 0 auto;
	    text-algin: center;
	}
	caption {
	    padding: 0 0 5px 0;
	    font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
	    text-align: center;
	}
	th {
	    font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
	    color: #4f6b72;
	    border-right: 1px solid #C1DAD7;
	    border-bottom: 1px solid #C1DAD7;
	    border-top: 1px solid #C1DAD7;
	    letter-spacing: 2px;
	    text-transform: uppercase;
	    text-align: left;
	    padding: 6px 6px 6px 12px;
	    background-color: #CAE8EA;
	}
	td {
	    border-right: 1px solid #C1DAD7;
	    border-bottom: 1px solid #C1DAD7;
	    background: #fff;
	    font-size:11px;
	    padding: 6px 6px 6px 12px;
	    color: #4f6b72;
	}
	td.alt {
	    background: #F5FAFA;
	    color: #797268;
	}
	/*---------for IE 5.x bug*/
	html>body td{ font-size:11px;}
	</style>
</head>

<body>
<table id="mytable" cellspacing="0">
<caption>比赛列表</caption>
  <tr>
  	<th>ID</th>
  	<th>来自</th>
	<th>比赛时间</th>
	<th>联赛名称</th>
	<th>主队</th>
	<th>客队</th>
	<th>主队ID</th>
	<th>客队ID</th>
	<th>玩法</th><!-- 上半场亚洲盘角球 | 亚洲盘角球 -->
	<th>盘口</th>
	<th>大水</th><!-- 赔率 -->
	<th>小水</th>
	<th>抓取时间</th>
	<th>添加时间</th>
  </tr>
  
<?php
require dirname(__FILE__) . '/checkuser.php';
require dirname(dirname(__FILE__)) . '/include/conf.php';
require dirname(dirname(__FILE__)) . '/include/database.php';

$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$page = $page > 0 ? $page : 1;

function read_ball_disc($db, $page){
	$page_size = 50;
	$offset = ($page - 1) * $page_size;
	$sql = "select * from ball_disc order by id desc limit {$offset}, {$page_size}";
	return $db->query($sql);
}

$db = db_touzhu();
$matchs = read_ball_disc($db, $page);
if (is_array($matchs) && !empty($matchs)){
	$counter = 1;
	foreach ($matchs as $match){
		echo '<tr>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['id'], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $GLOBAL_FROM[$match['from']], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['match_time'], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['match_name'], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['home_team'], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['visiting_team'], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['home_team_id'], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['visiting_team_id'], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $GLOBAL_WANFA_NUM[$match['wanfa']], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['pankou'], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['over'], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['under'], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['fetch_time'], '</td>';
		echo '<td',  ($counter % 2 == 0) ? ' class="alt"' : '', '>', $match['add_time'], '</td>';
		echo '</tr>';
		$counter ++;
	}
}
?>

<tr><td colspan="14" align="right">
	<a href="?page=1">第一页</a> | 
	<a href="?page=<?php echo ($page == 1) ? $page : $page - 1?>">上一页</a> | 
	<a href="?page=<?php echo $page + 1?>">下一页</a>
</td></tr>
</table>
</body>
</html>
